<template>
	<div class="canshu flex"  v-loading="loading" style="transition: all 0.2s;">
    <left2></left2>

    <div style="width: calc(100vw - 200px); height: 100vh; overflow: auto;" class="animate__animated animate__fadeIn">
      <div style="padding: 30px; ">
        <el-tabs v-model="activeName" type="card">


            <el-tab-pane label="通用参数" name="second">

              <div style="padding: 20px; font-weight: bold;">报警器设置</div>

              <div class="flexc" style="background: #FFFFff; padding-top: 30px;">
                <div class="flexc" style="margin-bottom: 20px; ">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>报警器</div>
                  <div>
                    <el-select v-model="all2.bjDev" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择报警器">
                        <el-option  v-for="item in xialaall.baojingqilist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>报警时长</div>
                  <div><el-input v-model="all2.bjTime" :disabled="all2.bjDev == 2" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px; margin-right: 20px;" placeholder="请输入报警时长（秒）"></el-input>秒</div>
                </div>
              </div>
              <div class="flexc" style="background: #FFFFff;">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>通信端口</div>
                  <div>
                    <el-select v-model="all2.txPort"  :disabled="all2.bjDev == 2" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择通信端口">
                        <el-option  v-for="item in xialaall.tongxinduankoulist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>波特率</div>
                  <div>
                    <el-select v-model="all2.btLv" :disabled="all2.bjDev == 2" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择波特率">
                        <el-option  v-for="item in xialaall.botelvlist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div class="flexc" style="background: #FFFFff;">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>数据位数</div>
                  <div><el-input v-model="all2.dataWei" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" :disabled="all2.bjDev == 2" style="width: 200px; margin-left: 30px;" placeholder="请输入数据位数"></el-input></div>
                </div>


                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>奇偶校验</div>
                  <div>
                    <el-select v-model="all2.jiOu" :disabled="all2.bjDev == 2" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择奇偶校验">
                        <el-option  v-for="item in xialaall.jioujiaoyanlist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div class="flexc" style="background: #FFFFff;">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>停止位 </div>
                  <div>
                    <el-select v-model="all2.stopFlag" :disabled="all2.bjDev == 2" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择停止位 ">
                        <el-option  v-for="item in xialaall.tingzhiweilist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div style="padding: 20px; font-weight: bold;">数据压缩设置</div>
              <div class="flexc" style="background: #FFFFff;">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 100px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>数据压缩</div>
                  <div style=" margin-left: 30px;">
                    <el-radio v-model="all2.dataCompress" :label="1" >压缩数据</el-radio>
                    <el-radio v-model="all2.dataCompress" :label="2" >不压缩数据</el-radio>
                  </div>
                </div>
              </div>

              <div style="padding-left: 120px; padding-bottom: 30px;"><el-button type="primary"  @click="baocun2()">保存</el-button></div>

            </el-tab-pane>
            <el-tab-pane label="高级参数" name="first">
              <div style="padding: 20px; font-weight: bold;">信号参数</div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>高通滤波阶次</div>
                  <div><el-input v-model="all.gtLvLevel" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入高通滤波阶次"></el-input></div>
                </div>
              </div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>速度高通信号截止频率</div>
                  <div><el-input v-model="all.sdGtLvEnd" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入速度高通信号截止频率"></el-input></div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>位移信号数据来源</div>
                  <div>
                    <el-select v-model="all.wyXhLy" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择位移信号数据来源">
                        <el-option  v-for="item in xialaall.xinhaolaiyuanlist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>

              </div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>位移高通信号截止频率</div>
                  <div><el-input v-model="all.wyGtLvEnd" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入位移高通信号截止频率"></el-input></div>
                </div>

              </div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>加速度信号附加长度</div>
                  <div><el-input v-model="all.jsdFjCd" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入加速度信号附加长度"></el-input></div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>速度信号附加长度</div>
                  <div>
                    <el-select v-model="all.sdXhCd" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择速度信号附加长度">
                        <el-option  v-for="item in xialaall.xinhaochangdulist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>

              <div style="padding: 20px; font-weight: bold;">转速范围参数</div>


              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>转速下限</div>
                  <div><el-input v-model="all.rpmMin" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入转速下限"></el-input></div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>转速上限</div>
                  <div><el-input v-model="all.rpmMax" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入转速上限"></el-input></div>
                </div>
              </div>

              <div style="padding: 20px; font-weight: bold;">长波形采集参数设置</div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>报警等级</div>
                  <div><el-input v-model="all.bjLevel" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入报警等级"></el-input></div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>采集间隔（小时）</div>
                  <div><el-input v-model="all.jgTime" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" style="width: 200px; margin-left: 30px;" placeholder="请输入采集间隔（小时）"></el-input></div>
                </div>
              </div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>开始时间</div>
                  <div >
                    <el-time-picker  v-model="all.startTime" style="width: 200px; margin-left: 30px;"  format="HH:mm" placeholder="请输入开始时间"></el-time-picker>

                  </div>
                </div>
              </div>

              <div style="padding: 20px; font-weight: bold;">奇数天采集参数</div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>信号类型</div>
                  <div>
                    <el-select v-model="all.jiXhType" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择信号类型">
                        <el-option  v-for="item in xialaall.xinhaoleixinglist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>分析频率</div>
                  <div>
                    <el-select v-model="all.jiAnalyze" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择分析频率">
                        <el-option  v-for="item in xialaall.fenxipinlvlist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>

              </div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>数据长度</div>
                  <div>
                    <el-select v-model="all.jiDataLength" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择速度信号附加长度">
                        <el-option  v-for="item in xialaall.xinhaochangdulist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div style="padding: 20px; font-weight: bold;">偶数天采集参数</div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>信号类型</div>
                  <div>
                    <el-select v-model="all.ouXhType" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择信号类型">
                        <el-option  v-for="item in xialaall.xinhaoleixinglist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>分析频率</div>
                  <div>
                    <el-select v-model="all.ouAnalyze" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择	分析频率">
                        <el-option  v-for="item in xialaall.fenxipinlvlist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div class="flexc">
                <div class="flexc" style="margin-bottom: 20px;">
                  <div style="width: 200px; text-align: right;"><span style="color: #f00; margin-right: 5px;">*</span>数据长度</div>
                  <div>
                    <el-select v-model="all.ouDataLength" style="width: 200px; margin-left: 30px;"  clearable filterable placeholder="请选择速度信号附加长度">
                        <el-option  v-for="item in xialaall.xinhaochangdulist" :key="item.value" :label="item.label" :value="item.value * 1"></el-option>
                    </el-select>
                  </div>
                </div>
              </div>
              <div style="padding-left: 220px; padding-bottom: 30px;"><el-button type="primary"  @click="baocun()">保存</el-button></div>

            </el-tab-pane>
          </el-tabs>

        </div>
      </div>


	</div>
</template>

<script>

  import { getsenior,getgeneral,postxiala,postgeneral,postsenior } from '@/api/shuju'
  import moment from "moment"
  import left2 from '../left2.vue'
	export default {
		name: 'zuzhiguanli',
    components:{
      left2
    },
		data() {
			return {
        loading:true,
        activeName: 'second',
        all:{
          "gtLvLevel":"",
          "sdGtLvEnd":"",
          "wyGtLvEnd":"",
          "jsdFjCd":"",
          "rpmMin":"",
          "rpmMax":"",
          "wyXhLy":"",
          "sdXhCd":"",
          "bjLevel":"",
          "jgTime":"",
          "startTime":"",
          "jiXhType":"",
          "jiAnalyze":"",
          "jiDataLength":"",
          "ouXhType":"",
          "ouAnalyze":"",
          "ouDataLength":"",
        },
        xialaall:{},

        all2:{
          "bjDev":"",
          "bjTime":"",
          "txPort":"",
          "btLv":"",
          "dataWei":"",
          "jiOu":"",
          "stopFlag":"",
          "dataCompress":""
        }
			}
		},
		created() {

      if(this.$store.state.one){
        this.loading = true
      }else{
        this.loading = false
      }

      var setv = setInterval(()=>{
        let obj11 = {
          sysName:"参数设置",
          dictName:"通用设置-数据压缩",
          dictType:""
        }
        postxiala(obj11).then(response => {
          this.xialaall.shujuyasuolist = response.data
          clearInterval(setv)
          this.loading = false
          this.$store.commit('changeone',false)

          Promise.all([this.getxialalist(),this.getxialalist1(),this.getxialalist2(),this.getxialalist3(),this.getxialalist4(),this.getxialalist5(),this.getxialalist6(),this.getxialalist7(),this.getxialalist8(),this.getxialalist9(),this.getxialalist10()]).then(()=>{
            getgeneral().then(response => {
              this.all2 = response.data
            })
            getsenior().then(response => {
              this.all = response.data
              this.all.startTime = moment(this.all.startTime, "HH:mm")
            })
          })
        })
      },1000)





		},
		mounted() {

		},
		methods: {

      baocun:function(){
        // if(!this.all.gtLvLevel || !this.all.sdGtLvEnd || !this.all.wyGtLvEnd || !this.all.jsdFjCd || !this.all.rpmMin || !this.all.rpmMax || !this.all.wyXhLy || !this.all.sdXhCd ||
        // !this.all.bjLevel || !this.all.jgTime || !this.all.startTime || !this.all.jiXhType || !this.all.jiAnalyze || !this.all.jiDataLength || !this.all.ouXhType || !this.all.ouAnalyze || !this.all.ouDataLength){
        //   this.$message.error('请填写完整参数');
        //   return
        // }
        let obj = JSON.parse(JSON.stringify(this.all))
        obj.startTime = moment(obj.startTime).format("HH:mm")
        postsenior(obj).then(response => {
          this.$message.success('保存成功');
        })
      },
      baocun2:function(){
        // if(!this.all2.bjDev || !this.all2.bjTime || !this.all2.txPort || !this.all2.bjDev || !this.all2.btLv || !this.all2.dataWei || !this.all2.jiOu || !this.all2.stopFlag || !this.all2.dataCompress){
        //   this.$message.error('请填写完整参数');
        //   return
        // }
        postgeneral(this.all2).then(response => {
          this.$message.success('保存成功');
        })
      },

      getxialalist1:function(){
        return new Promise((res,rej)=>{
          let obj = {
            sysName:"参数设置",
            dictName:"高级设置-位移信号数据来源",
            dictType:""
          }

          postxiala(obj).then(response => {
            this.xialaall.xinhaolaiyuanlist = response.data
          })
          res()
        })
      },
      getxialalist2:function(){
        return new Promise((res,rej)=>{
          let obj2 = {
            sysName:"参数设置",
            dictName:"高级设置-速度信号附加长度",
            dictType:""
          }
          postxiala(obj2).then(response => {
            this.xialaall.xinhaochangdulist = response.data
          })
          res()
        })
      },
      getxialalist3:function(){
        return new Promise((res,rej)=>{
          let obj3 = {
            sysName:"参数设置",
            dictName:"高级设置-信号类型",
            dictType:""
          }
          postxiala(obj3).then(response => {
            this.xialaall.xinhaoleixinglist = response.data
          })
          res()
        })
      },
      getxialalist4:function(){
        return new Promise((res,rej)=>{
          let obj4 = {
            sysName:"参数设置",
            dictName:"高级设置-分析频率",
            dictType:""
          }
          postxiala(obj4).then(response => {
            this.xialaall.fenxipinlvlist = response.data
          })
          res()
        })
      },
      getxialalist5:function(){
        return new Promise((res,rej)=>{
          let obj5 = {
            sysName:"参数设置",
            dictName:"高级设置-数据长度",
            dictType:""
          }
          postxiala(obj5).then(response => {
            this.xialaall.shujuchangdulist = response.data
          })
          res()
        })
      },
      getxialalist6:function(){
        return new Promise((res,rej)=>{
          let obj6 = {
            sysName:"参数设置",
            dictName:"通用设置-报警器",
            dictType:""
          }
          postxiala(obj6).then(response => {
            this.xialaall.baojingqilist = response.data
          })
          res()
        })
      },
      getxialalist7:function(){
        return new Promise((res,rej)=>{
          let obj7 = {
            sysName:"参数设置",
            dictName:"通用设置-通讯端口",
            dictType:""
          }
          postxiala(obj7).then(response => {
            this.xialaall.tongxinduankoulist = response.data
          })
          res()
        })
      },
      getxialalist8:function(){
        return new Promise((res,rej)=>{
          let obj8 = {
            sysName:"参数设置",
            dictName:"通用设置-波特率",
            dictType:""
          }
          postxiala(obj8).then(response => {
            this.xialaall.botelvlist = response.data
          })
          res()
        })
      },
      getxialalist9:function(){
        return new Promise((res,rej)=>{
          let obj9 = {
            sysName:"参数设置",
            dictName:"通用设置-奇偶校验",
            dictType:""
          }
          postxiala(obj9).then(response => {
            this.xialaall.jioujiaoyanlist = response.data
          })
          res()
        })
      },
      getxialalist10:function(){
        return new Promise((res,rej)=>{
          let obj10 = {
            sysName:"参数设置",
            dictName:"通用设置-停止位",
            dictType:""
          }
          postxiala(obj10).then(response => {
            this.xialaall.tingzhiweilist = response.data
          })

          res()
        })
      },

      //获取下啦数据用
      getxialalist:function(){
        let obj11 = {
          sysName:"参数设置",
          dictName:"通用设置-数据压缩",
          dictType:""
        }
        postxiala(obj11).then(response => {
          this.xialaall.shujuyasuolist = response.data
        })

      },
		}
	}
</script>


<style scoped lang="less">
  .canshu{
    /deep/ .el-tabs__header{ margin: 0;}
    /deep/ .el-tabs__content{ background: #fff;}
    /deep/ .el-tabs__item.is-active{ background: #fff;}
  }
</style>
